 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Step 3: Spawn Creation</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta content="no-cache" />
<link href="CSS/default.css" rel="stylesheet" type="text/css" />
</head>

<cfinclude template="authentication.cfm">  
<cfinclude template="functions.cfm">  

<cfif Session.bolAuth EQ True and (Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR)>	
	<cfif not isdefined("Session.intUserRosettaID")>
    	<cfoutput>
        <body>
        <!-- start header -->
            <cfinclude template="header.cfm"/>
        <!-- end header -->
            <div id="page">	
                Session Expired.  Click <a href="Step3-Orientation1.cfm">here</a> to redirect to the Orientation main page.
            </div>
        </body>
        </cfoutput>
    <cfelseif isdefined("URL.ID")>
    	
        <cfquery name="qryGetEmpInfoByStep" datasource="EPAR">
            scf_GetEmpInfoByStep #URL.ID#
        </cfquery>
        
		<cfif qryGetEmpInfoByStep.recordcount EQ 0>
			<cfoutput>
            <body>
            <!-- start header -->
                <cfinclude template="header.cfm"/>
            <!-- end header -->
                <div id="page">	
            		This employee has already been processed in Step 3.   To select another user, click <a href="Step3-Orientation1.cfm">Here</a>
                </div>
            </body>
            </cfoutput>
            
    	<cfelse>
			<!--- Declare Constants --->
            <cfset DOMAINCONTROLLER = "10.100.1.101">
            <cfset USA = 5>
            <cfset ORG_SCF = 117>
            <cfset PRIMARY_POS = -1>
            <cfset PROMOTION = -1>
            <cfset BASEPAY = -1>
            <cfset COMP_LOCATION_FACTOR = 1.00>
            <cfset ACTIVE = -10131>
            <cfset I9_PENDING = -10157>
            <cfset DOLLARS = 2>
            <cfset EMP_ADDRESS_TYPE = 17>
			<cfset REHIRE = 3>
                <!---From tEmployment_Codes--->
                <cfset ES_REASON_NEW_HIRE = 5>  <!---ES=EMPLOYMENT--->
                <cfset PS_REASON_NEW_HIRE = 53> <!---PS=PAY--->
                <cfset PP_REASON_NEW_HIRE = 44> <!---PP=POSITION--->
				<cfset ES_REHIRE = 6>  <!---ES=EMPLOYMENT--->
                <cfset PS_REHIRE = 54> <!---PS=PAY--->
                <cfset PP_REHIRE = 45> <!---PP=POSITION--->
                <!---END tEmployment_Codes--->
            <!--- End Constants --->
            
            <cfset strEmpResult ="">  	<!--- AD --->
            <cfset strRosResult ="">  	<!--- AD --->
            <cfset intNewHRID =0>		<!--- HR --->   
            <cfset dteCurrent = dateformat(now(),'mm/dd/yyyy')> <!--- HR ---> 
            <cfset intStepID =0>
            <cfset intEmpID =0>
			<cfset bolError = False>
            
            <cfset intStepID =URL.ID>
        	<cfset intEmpID = qryGetEmpInfoByStep.ID>
            <cfquery name="qryGetEmpInfo" datasource="EPAR"> 
                scf_GetEmpInfo #intEmpID#
            </cfquery>
            
            <cfquery name="qryGetEmpECInfo" datasource="EPAR"> 
                scf_GetEmpContactInfo #intEmpID#, 2
            </cfquery>
            
            <cfloop query="qryGetEmpInfo">
                
                <!--- Declare Strings --->
                <cfset strFirst = First>			<!--- AD & HR --->
                <cfset strLast = replace(Last,".", "", "all")>				<!--- AD & HR --->
                <cfset strMiddle = Middle>			<!--- AD & HR --->
                <cfset strPreferred = PreferredName><!--- AD & HR --->
                <cfset strSSN = SSN>				<!--- HR --->
                <cfset strPhone = DeskPhone>		<!--- AD --->
                <cfset strAddress1 = Address1>		<!--- HR --->
                <cfset strAddress2 = Address2>		<!--- HR --->
                <cfset strCity = City>				<!--- HR --->
                <cfset strZIP = ZIP>				<!--- HR --->
                <cfset strHomePhone = DisplayPhone(HomePhone)>	<!--- HR --->
                <cfset strCellPhone = DisplayPhone(CellPhone)>	<!--- HR --->
                <cfset strWorkPhone = DisplayPhone(WorkPhone)>	<!--- HR --->
                <cfset strWorkExt = WorkPhoneExt>	<!--- HR --->
                <cfset strEmployeeNameDisplay = strFirst> <!--- Display Only --->
                <cfif trim(strMiddle) NEQ ''>
                    <cfset strEmployeeNameDisplay &= ' #strMiddle#'>
                </cfif>
                <cfif trim(strPreferred) NEQ ''>
                    <cfset strEmployeeNameDisplay &= ' (#strPreferred#)'>
                </cfif>
                <cfset strEmployeeNameDisplay &= ' #strLast#'>
                <cfset strJobDesc = "">
                <cfset strJobTitle = "">
                <cfset strContainer = "">   
                <cfset strHomeDirLoc = "">  
                <!--- End Strings --->
                
                
                <!--- Declare Dates --->
                <cfset dteDOB = DateFormat(DOB,'mm/dd/yyyy')>				<!--- HR --->
                <cfset dteHire = DateFormat(ActStartDate,'mm/dd/yyyy')>		<!--- HR --->
                <!--- End Dates --->
                
                
                <!--- Declare Integers (property flags) --->
                <cfset intPosID = PositionID>					<!--- AD & HR --->
                <cfset intDeptID = DeptID>						<!--- AD & HR --->
                <cfset intMirrorID = MirrorAccountID>			<!--- AD --->
                <cfset intContainerID = ContainerID>			<!--- AD --->
                <cfset intCompTypeID = CompTypeID>				<!--- HR --->
                <cfset intEmploymentCodeID = EmpCodeID>			<!--- HR --->
                <cfset intEthnicCodeID = EthnicID>				<!--- HR --->
                <cfset intFreqID = FrequencyID>					<!--- HR --->
                <cfset intGenderID = GenderID>					<!--- HR --->
                <cfset intHrsPerWk = HoursPerWeek>				<!--- HR --->
                <cfset intI9OnFileID = I9>						<!--- HR --->
                <cfset intMaritalStatusID = MaritalStatusID>	<!--- HR --->
                <cfset intADSupervisorID = SupervisorID>		<!--- HR --->  <!---CONVERT TO HR PersonIDNo--->
                <cfset intSalaryHourlyID = SalaryHourlyID>		<!--- HR --->
                <cfset intWrksCompID = WorkersCompID>			<!--- HR --->
                <cfset intStateID = State>						<!--- HR --->
                <cfset intPhonePrimaryID = PhonePrimaryID>		<!--- HR --->
				
                <cfquery name="qryGetAF" datasource="WFCDB">
                    Select AnnualizingFactor
                    From tSY_PAY_RATE_FREQUENCY_CODES
                    Where PayRateFrequencyCodeDomainIDNo = #intFreqID#
                </cfquery>   
                
                <cfset arrSup = SCF_Employee_GetEmployeeInfo_Basic(intADSupervisorID)>
                <cfset strSupEmail = arrSup.Email>
<!---TEMPORARY ONLY - During ANMC's transition to ANTHC domain accounts (STJ 2/3/2008)--->
                <cfset strSupEmail = replace(strSupEmail, "anmc", "anthc")>
<!---END TEMP FIX--->
                <cfset strSupUserID = arrSup.Login>
                 
                <cfset intAnnualizingFactor = qryGetAF.AnnualizingFactor>		<!--- HR --->
                <!--- End Integers --->
                
                
                <!--- Declare Floats --->
                <cfset fltPayRate = PayRate>									<!--- HR --->
                <cfset fltAnnualSalary = fltPayRate * intAnnualizingFactor>		<!--- HR --->
                <!--- End Floats --->
                
                
                <!---Declare Booleans --->      
                <cfif intSalaryHourlyID EQ -10192>
                    <cfset bolExempt = -1>
                <cfelse>
                    <cfset bolExempt = 0>
                </cfif>        
                <cfif FullTime>
                    <cfset bolFullTime = -1>
                <cfelse>
                    <cfset bolFullTime = 0>
                </cfif>    
                <cfif Seasonal>
                    <cfset bolSeasonal = -1>
                <cfelse>
                    <cfset bolSeasonal = 0>
                </cfif>
                <!---End Booleans --->
                        
            </cfloop>
               
            <body>
			
            <cfthread name="thdAD" action="run" priority="low"> 
            	<cfset thread.strTrace = "start">
                <cfset thread.bolADStarted = True>
				<cfset HOMEDIR = "G:">
                <cfset MAILSERVER = "SCFMX">  
                <cfset thread.strADResult ="Error Occured Creating AD Account"> <!---"<strong>Account Created Successfully</strong>"--->
                <cfset thread.lngResult = 0>  
                <cfset thread.strNewUserID = ""> <!---"xTest1"--->
                <cfset thread.strNewADGUID = "">  
				<cfset thread.strTempResult =""> 
            	<cfset thread.bolWarning = False>          
                
                <cftry>
                    
                	<cfset thread.strTrace = "1">  
                    <cfquery name="qryGetPosition" datasource="WFCDB">
                        Select PositionIDNo, PositionCode, PositionCodeDescription
                        From tPosition_Codes 
                        Where PositionCodeToEffectDate ='1/1/3000' and PositionIDNo = #intPosID#
                    </cfquery>
                    
                    <cfset variables.strJobDesc = qryGetPosition.PositionCodeDescription & ' (' & trim(qryGetPosition.PositionCode) & ')'>
                    <cfset variables.strJobTitle = qryGetPosition.PositionCodeDescription>
                    
                    <cfquery name="qryGetDept" datasource="WFCDB">
                        Select OrganizationDescription 
                        From tOrganizations
                        Where OrganizationToEffectDate = '1/1/3000' and OrgCodeIdNo = #intDeptID#
                    </cfquery>  
                    <cfset strDept = qryGetDept.OrganizationDescription> 
                    
					<!--- Commented, 3/16/2008, STJ - to handle ASTP instances (or anyone else where a mirror account was not provided
                    <cfset arrMirror = SCF_Employee_GetEmployeeInfo_Basic(intMirrorID)>
                    <cfset strMirror = arrMirror.Login>
                    --->					
					<cfif intMirrorID NEQ 0>
                    	<cfset arrMirror = SCF_Employee_GetEmployeeInfo_Basic(intMirrorID)>
                    	<cfset strMirror = arrMirror.Login>
					<cfelse>
                    	<cfset strMirror = "EPARBasic">
					</cfif>
					<!---END 3/16/2009 Mods--->
                    
                    <cfquery name="qryGetNextMailServer" datasource="EPAR">
                        scf_GetNextServer
                    </cfquery>
                    <cfset intMailServer=qryGetNextMailServer.ServerID>
                    <!---cfset strMailServer = MAILSERVER & intMailServer--->  
                    <cfset strMailServer = qryGetNextMailServer.ServerName>        
                    
                    <cfquery name="qryGetContainer" datasource="EPAR">
                        scf_GetContainers #intContainerID#
                    </cfquery>		
                    <cfset variables.strContainer = qryGetContainer.Container>   
                    <cfset variables.strHomeDirLoc = qryGetContainer.HomeDir>          
                    
                    <cfset thread.strADResult = "Error Occured Creating AD Account - .NET Creation">
                     
                    <!---cfobject type="dotnet" name="objCreation" class="AccountCreation.Creation" assembly ="C:\Program Files\Southcentral Foundation\AccountCreation\AccountCreation.dll"--->  
                    <cfobject type="dotnet" name="objCreation" class="ADTools.Creation" assembly ="C:\Program Files\Southcentral Foundation\ADTools\ADTools.dll">       
                   	
                	<cfset thread.strTrace = "2">  
					<!--- CHANGED 6/3/2008, STJ, ManagerUserID changed to ManagerEmail--->
                    <!---cfset thread.lngResult = objCreation.CreateUser(#DOMAINCONTROLLER#, #replace(strFirst," ","")#, #strMiddle#, #replace(strLast," ","")#, 
						#strPreferred#, #strSupUserID#, #objCreation.SCF#, #strDept#, #variables.strJobTitle#, #variables.strJobDesc#, #variables.strHomeDirLoc#, 
						#HOMEDIR#, #strMailServer#, "OU=" & variables.strContainer & ";", #strPhone#, #strMirror#, "", 2000)--->  
                    <cfset thread.lngResult = objCreation.CreateUser(#DOMAINCONTROLLER#, #replace(strFirst," ","")#, #strMiddle#, #replace(strLast," ","")#, 
						#strPreferred#, #strSupEmail#, #objCreation.SCF#, #strDept#, #variables.strJobTitle#, #variables.strJobDesc#, #variables.strHomeDirLoc#, 
						#HOMEDIR#, #strMailServer#, "OU=" & variables.strContainer & ";", #strPhone#, #strMirror#, "", 10000)>   
						<!---OU=CreationTest;OU=TempUsersOU;--->
                        
                    <!---cfset thread.strADResult = "Error Occured Creating AD Account - Post .NET Creation Result =" & thread.lngResult--->
                    
                    
                	<cfset thread.strTrace = "3">  
                    <cfif thread.lngResult NEQ 0>
                        <cfset thread.strADResult = replace(replace(replace(replace(objCreation.GetErrorText(),chr(13),'<BR/>','all'), chr(10), '','all'),'<BR/>',''),'<BR/><BR/>','')  />   
                        <cfif thread.lngResult EQ -2><!---Warning only--->
                        	<cfset thread.bolSuccess = True>
                        	<cfset thread.bolWarning = True>
                        <cfelse>
                        	<cfset thread.bolSuccess = False> 
                        </cfif>
                        
                    <cfelse>    
                        <cfset thread.bolSuccess = True>  
						<cfset thread.strADResult =  ''>                     
                        
                    </cfif>    
                    
                    <!---cfif thread.bolSuccess>
                    	<cfset thread.lngResult = 0>
                        <cfset thread.strNewUserID = objCreation.GetNewLogin() />   
                        <cfset thread.strNewADGUID = objCreation.GetGUID(thread.strNewUserID)/>  
                        <cfif intMailServer GTE 3>
                            <cfset intNext = 1>
                        <cfelse>		
                            <cfset intNext = intMailServer+ 1>
                        </cfif>            
                        <cfquery name ="qryUpdateNextServer" datasource="Employee">
                            Update NextMailServer 
                            Set ServerID = #intNext#
                        </cfquery>
                        
                        <cfset thread.strADResult =thread.strADResult & "<strong>Account Created Successfully</strong>"> 
                		<cfset variables.bolError = False>  
                        
                    <cfelse>
                        <cfset thread.strNewUserID = ""> 
                        <cfset variables.bolError = True>
                    </cfif--->
                	<cfset thread.strTrace = "4">  
					<cfif thread.bolSuccess>
                    	<cfset thread.lngResult = 0>
                        <cfset thread.strNewUserID = objCreation.GetNewLogin() />   
                        <cfset thread.strNewADGUID = objCreation.GetGUID(thread.strNewUserID, "", "")/>
                        
                		<cfset thread.strTrace = "4.1">  
                        <cfif intMailServer GTE 3>
                            <cfset intNext = 1>
                        <cfelse>		
                            <cfset intNext = intMailServer + 1>
                        </cfif>   
                               
                		<cfset thread.strTrace = "4.2">  
                        <cfquery name ="qryUpdateNextServer" datasource="EPAR">
                            scf_UpdateNextServer #intNext#
                        </cfquery>
                        
                		<cfset thread.strTrace = "4.3">  
                        <cfset thread.strTempResult ="<strong>Account Created Successfully</strong>">
                        <cfif thread.bolWarning EQ True> 
                        	 <cfset thread.strTempResult = thread.strTempResult & "<BR><u>WARNING</u>:&nbsp;&nbsp;">
                        </cfif>
                        <cfset thread.strADResult = thread.strTempResult & thread.strADResult> 
                		<cfset variables.bolError = False>  
                        
                		<cfset thread.strTrace = "4.4">  
                        <cfif thread.bolWarning EQ True>
                        	<!--- Send notice to the helpdesk that some action is required--->                            
                            <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Warning@scf.cc" subject="EPAR Warning:  Creating Active Directory Account" type="html">
                                Error generating the Active Directory record<BR /><BR />
                                Result: #thread.lngResult# #thread.strADResult# <!---#thread.bolSuccess# #thread.bolWarning#--->
                            </cfmail>
                        </cfif>
                        
                    <cfelse>
                		<cfset thread.strTrace = "4.5">  
                        <cfset thread.strNewUserID = ""> 
                        <cfset thread.strADResult = thread.strADResult & " " & thread.strTrace> 
                        <cfset variables.bolError = True>
                        <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Error@scf.cc" subject="EPAR Error:  Creating Active Directory Account" type="html">
                            Error generating the Active Directory record<BR /><BR />
                            Trace: #thread.strTrace#<BR />
                            Result: #thread.lngResult# #thread.strADResult#<BR />
							DLL Call: objCreation.CreateUser(#DOMAINCONTROLLER#, #replace(strFirst," ","")#, #strMiddle#, #replace(strLast," ","")#, 
						#strPreferred#, #strSupEmail#, #objCreation.SCF#, #strDept#, #variables.strJobTitle#, #variables.strJobDesc#, #variables.strHomeDirLoc#, 
						#HOMEDIR#, #strMailServer#, "OU=" & #variables.strContainer# & ";", #strPhone#, #strMirror#, "", 10000)
                        </cfmail>
                        
                    </cfif>
                                    
                   
                	<cfset strTrace = "5">  
                    <cfcatch type="any">
                        <cfset thread.strADResult = CFCATCH.Detail>
                        <cfset thread.strNewUserID = "">  
                        <cfset thread.lngResult = -1>
                        <cfset variables.bolError = True>
                        <cfquery name="qryInsertErrorLog" datasource="EPAR">
                            scf_InsertErrorLog #intStepID#, '#Session.intUserRosettaID#', N'Error generating the Active Directory record: #CFCATCH.Detail#  Trace: #thread.strTrace#  Result:#thread.lngResult# #thread.strADResult#' 
                        </cfquery>
                        <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Error@scf.cc" subject="EPAR Error:  Creating Active Directory Account" type="html">
                            Error generating the Active Directory record: #CFCATCH.Detail#<BR />
                            Trace: #thread.strTrace#
                        </cfmail>
                    </cfcatch>
        
                </cftry>
                         
                 
                <!--- For display purposes only --->     
                <cfscript> 
                    sleep(1500);
                </cfscript>   
            </cfthread>
             
                
            <cfthread name="thdHRProd" action="run" priority="low"> 
               	<cfset thread.bolHRStarted = False>  
				<cfset thread.lngResult = 0>
                <cfset thread.intNewHRPersonIDNo = 0><!---7673--->
				<cfset thread.intReHirePersonIDNo = 0>
                <cfset thread.strHRResult =""> <!---'<strong>Success</strong>'--->  
                <cfset strSQL = "">
                
                <cftry>
                    <cfloop condition="thdAD.Status NEQ 'COMPLETED' and thdAD.Status NEQ 'TERMINATED'"> 
                        <cfscript>
                            sleep(100);
                        </cfscript>
                    </cfloop>
                    
                    
               		<cfset thread.bolHRStarted = True>
                    <cfif thdAD.Status EQ 'COMPLETED' and thdAD.lngResult EQ 0 and not variables.bolError>
                        <cfset intHRSupID = SCF_HR_MasterID_to_HRPersonID (intADSupervisorID)>
                        
                        
                        <!--- REHIRE CHECK--->  
						<cfquery name="qryCheckRehire" datasource="EPAR">
							scf_SCFVM18_CheckRehire '#strSSN#'
						</cfquery>    
                        <!---cfquery name="qryCheckRehire" datasource="WFCSuiteTest">
                            Select PersonIDNo From tPersons
                            Where PersonTaxIDNo = '#strSSN#'
                        </cfquery--->   
                        
                        <cfif qryCheckRehire.recordcount GT 0>
                            <!--- Person already exists in our system ... REHIRE --->
                            
                			<cfset thread.intReHirePersonIDNo =  qryCheckRehire.PersonIDNo>
							<cfset thread.intNewHRPersonIDNo = thread.intReHirePersonIDNo><!--- For check later in Rosetta Thread--->
                            <cfset strSQL = "scf_SCFVM18_RehireStep1 #thread.intReHirePersonIDNo#, #intPosID#, #PP_REHIRE#, '#dteHire#', #intHRSupID#, #PRIMARY_POS#, #PROMOTION#, #bolExempt#, #intSalaryHourlyID#, #bolSeasonal#, #intHrsPerWk#, #intWrksCompID#, #COMP_LOCATION_FACTOR#, #PS_REHIRE#, #intCompTypeID#, #intFreqID#, #fltPayRate#, #intAnnualizingFactor#, #fltAnnualSalary#, #BASEPAY#, #DOLLARS#, #ACTIVE#, #intEmploymentCodeID#, #bolFullTime#, #intI9OnFileID#, #ORG_SCF#, #ES_REHIRE#, #REHIRE#, '#dteDOB#', '#strFirst#', '#strLast#', #intMaritalStatusID#, '#strMiddle#', '#strPreferred#', #intEthnicCodeID#, #intGenderID#, '#strSSN#', '#thdAD.strNewUserID#'  ">
                            <!---cfquery name="qryRehireEmployee" datasource="WFCSuiteTest">                                        
                                scf_RehireStep1 #thread.intReHirePersonIDNo#, #intPosID#, #PP_REHIRE#, '#dteHire#', #intHRSupID#, #PRIMARY_POS#, #PROMOTION#, #bolExempt#, 
                                    #intSalaryHourlyID#, #bolSeasonal#, #intHrsPerWk#, #intWrksCompID#, #COMP_LOCATION_FACTOR#, #PS_REHIRE#, #intCompTypeID#, 
                                    #intFreqID#, #fltPayRate#, #intAnnualizingFactor#, #fltAnnualSalary#, #BASEPAY#, #DOLLARS#, #ACTIVE#, #intEmploymentCodeID#, 
                                    #bolFullTime#, #intI9OnFileID#, #ORG_SCF#, #ES_REHIRE#, #REHIRE#, '#dteDOB#', '#strFirst#', '#strLast#', #intMaritalStatusID#,
                                    '#strMiddle#', '#strPreferred#', #intEthnicCodeID#, #intGenderID#, '#strSSN#', '#thdAD.strNewUserID#'  
                        	</cfquery--->             
                        	<!---cfstoredproc datasource="WFCSuiteTest" procedure="scf_RehireStep1"---> 
                        	<cfstoredproc datasource="EPAR" procedure="scf_SCFVM18_RehireStep1"> 
								<cfprocparam cfsqltype="cf_sql_integer" value="#thread.intReHirePersonIDNo#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intPosID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PP_REHIRE#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#dteHire#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intHRSupID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PRIMARY_POS#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PROMOTION#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#bolExempt#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intSalaryHourlyID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#bolSeasonal#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intHrsPerWk#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intWrksCompID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#COMP_LOCATION_FACTOR#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PS_REHIRE#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intCompTypeID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intFreqID#">
								<cfprocparam cfsqltype="cf_sql_float" value="#fltPayRate#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intAnnualizingFactor#">
								<cfprocparam cfsqltype="cf_sql_float" value="#fltAnnualSalary#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#BASEPAY#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#DOLLARS#">    
								<cfprocparam cfsqltype="cf_sql_integer" value="#ACTIVE#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intEmploymentCodeID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#bolFullTime#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intI9OnFileID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#ORG_SCF#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#ES_REHIRE#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#REHIRE#">
								<cfprocparam cfsqltype="cf_sql_date" value="#dteDOB#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strFirst#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strLast#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intMaritalStatusID#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strMiddle#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strPreferred#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intEthnicCodeID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intGenderID#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strSSN#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#thdAD.strNewUserID#">         
								<cfprocresult name="NewID" resultset="1">
								<cfprocresult name="ErrorCheck" resultset="2">
							</cfstoredproc>  
                            
                            <cfset thread.lngResult = ErrorCheck.Error>
							<cfif thread.lngResult EQ 0>
								<!---Step 1 (Rehiring the Employee) was successful, now let's move on to Step 2, Adding Addresses and Phone Numbers--->
                                <!---cfquery name="qryPrimePhones" datasource="WFCSuiteTest"--->
                                <cfquery name="qryPrimePhones" datasource="EPAR">
                                   	scf_SCFVM18_PrimePhones #thread.intReHirePersonIDNo#, '#dateformat(dateadd('d', -1, dteHire),'mm/dd/yyyy')#'
                                </cfquery>
								<cfset strSQL = "scf_SCFVM18_CreationStep2_AddressesPhones #thread.intReHirePersonIDNo#, '#dteHire#', #EMP_ADDRESS_TYPE#, '#strAddress1#', '#strAddress2#', '#strCity#', #intStateID#, '#strZIP#', #USA#, '#strHomePhone#', '#strCellPhone#', '#strWorkPhone#', '#strWorkExt#', #intPhonePrimaryID#  ">
                                <!---cfquery name="qryRehireEmployee_AddressesPhones" datasource="WFCSuiteTest"--->
                                <cfquery name="qryRehireEmployee_AddressesPhones" datasource="EPAR">
                                    scf_SCFVM18_CreationStep2_AddressesPhones #thread.intReHirePersonIDNo#, '#dteHire#', #EMP_ADDRESS_TYPE#, '#strAddress1#', '#strAddress2#',
                                        '#strCity#', #intStateID#, '#strZIP#', #USA#, '#strHomePhone#', '#strCellPhone#', '#strWorkPhone#', '#strWorkExt#', #intPhonePrimaryID#
                                </cfquery>
                                
                                <cfset thread.lngResult = qryRehireEmployee_AddressesPhones.Error>
                                <cfif thread.lngResult EQ 0>
									<!---Step 2 was successful, now let's move on to Step 3, Emergency Contacts --->
									<cfset intContactOrder = 1>
									<cfloop query="qryGetEmpECInfo">   
										<cfset strECHomePhone = DisplayPhone(HomePhone)>	
										<cfset strECCellPhone = DisplayPhone(CellPhone)>	
										<cfset strECWorkPhone = DisplayPhone(WorkPhone)>	
                                        
                                        
										<cfset strSQL = "scf_SCFVM18_CreationStep3_EmergencyContact #thread.intReHirePersonIDNo#, '#dteHire#', '#First#', '#Last#', #RelationID#, #intContactOrder#, #EMP_ADDRESS_TYPE#, '#Address1#', '#Address2#', '#City#', #State#, '#ZIP#', #USA#, '#strECHomePhone#', '#strECCellPhone#', '#strECWorkPhone#', '#WorkPhoneExt#', #PhonePrimaryID#	  ">
										<!---cfquery name="qryRehireEmployee_EmergencyContacts" datasource="WFCSuiteTest"--->        
										<cfquery name="qryRehireEmployee_EmergencyContacts" datasource="EPAR">          
											scf_SCFVM18_CreationStep3_EmergencyContact #thread.intReHirePersonIDNo#, '#dteHire#', '#First#', '#Last#', #RelationID#, #intContactOrder#,
												 #EMP_ADDRESS_TYPE#, '#Address1#', '#Address2#', '#City#', #State#, '#ZIP#', #USA#, '#strECHomePhone#', '#strECCellPhone#', 
												 '#strECWorkPhone#', '#WorkPhoneExt#', #PhonePrimaryID#	
										</cfquery>
										
										<cfif qryRehireEmployee_EmergencyContacts.Error NEQ 0>
											<cfset thread.strHRResult &= "Error creating Emergency Contact record for #First# #Last#.  Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">
											<cfset thread.lngResult = qryRehireEmployee_EmergencyContacts.Error>
										</cfif>
										
										<cfset intContactOrder += 1> 
										
									</cfloop>
													   
									<cfif thread.strHRResult EQ ''>
										<cfset thread.lngResult = 0>
									</cfif> 
									
								<cfelse>
									<!--- Error.  Don't proceed.  Post a description of what was successful and what must still be done by hand --->
									<cfset thread.strHRResult &= "The rehire action on HR record was successful but there was an error adding the Employee\'s address(es) and phone(s).  The Address(es) and Phone(s) and Emergency Contacts (if any) must still be added.  Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">
												   
								</cfif>
                                
							<cfelse>
								<!--- Error.  Don't proceed.  Post a description of what was successful and what must still be done by hand --->  
									<cfset thread.strHRResult &= "There was an error during the rehire HR action for the Employee.  The Employment Status, Pay, Personal Information, Address(es), Phone(s) and Emergency Contacts (if any) may still need to be added.  Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">  
                                
                        	</cfif>
                            
                        <cfelse>
                        	<!--- HIRE NORMALLY --->   
							<cfset strSQL = "scf_SCFVM18_CreationStep1_CreateEmployee '#dteDOB#', '#dteHire#', '#strFirst#', '#strLast#', '#strPreferred#', '#strMiddle#', '#strSSN#', #intMaritalStatusID#, #intEthnicCodeID#, #intGenderID#,#intPosID#, #PP_REASON_NEW_HIRE#, #intHRSupID#, #PRIMARY_POS#, #PROMOTION#, #bolExempt#, #intSalaryHourlyID#, #bolSeasonal#, #intHrsPerWk#, #intWrksCompID#, #COMP_LOCATION_FACTOR#, #ACTIVE#, #bolFullTime#, #I9_PENDING#, #ORG_SCF#, #intEmploymentCodeID#, #intI9OnFileID#, #ES_REASON_NEW_HIRE#, #PS_REASON_NEW_HIRE# , #intCompTypeID#, #intFreqID#, #fltPayRate#, #intAnnualizingFactor#, #fltAnnualSalary#, #BASEPAY#, #DOLLARS#, '#thdAD.strNewUserID#'">                         
                        	<!---cfstoredproc datasource="WFCSuiteTest" procedure="scf_CreationStep1_CreateEmployee"--->  
                        	<cfstoredproc datasource="EPAR" procedure="scf_SCFVM18_CreationStep1_CreateEmployee">  
								<cfprocparam cfsqltype="cf_sql_date" value="#dteDOB#">
								<cfprocparam cfsqltype="cf_sql_date" value="#dteHire#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strFirst#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strLast#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strPreferred#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strMiddle#">
								<cfprocparam cfsqltype="cf_sql_varchar" value="#strSSN#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intMaritalStatusID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intEthnicCodeID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intGenderID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intPosID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PP_REASON_NEW_HIRE#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intHRSupID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PRIMARY_POS#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PROMOTION#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#bolExempt#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intSalaryHourlyID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#bolSeasonal#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intHrsPerWk#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intWrksCompID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#COMP_LOCATION_FACTOR#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#ACTIVE#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#bolFullTime#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#I9_PENDING#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#ORG_SCF#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intEmploymentCodeID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intI9OnFileID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#ES_REASON_NEW_HIRE#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#PS_REASON_NEW_HIRE#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intCompTypeID#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intFreqID#">
								<cfprocparam cfsqltype="cf_sql_float" value="#fltPayRate#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#intAnnualizingFactor#">
								<cfprocparam cfsqltype="cf_sql_float" value="#fltAnnualSalary#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#BASEPAY#">
								<cfprocparam cfsqltype="cf_sql_integer" value="#DOLLARS#">    
								<cfprocparam cfsqltype="cf_sql_varchar" value="#thdAD.strNewUserID#">         
								<cfprocresult name="NewID" resultset="1">
								<cfprocresult name="ErrorCheck" resultset="2">
							</cfstoredproc>            
                        
							<cfset thread.lngResult = ErrorCheck.Error>
							<cfif thread.lngResult EQ 0>
								<!---Step 1 (Creating the employee Record was successful, now let's move on to Step 2, Adding Addresses and Phone Numbers--->
								<!---cfset thread.intNewHRPersonIDNo = 0--->
								<cfset thread.intNewHRPersonIDNo = NewID.COMPUTED_COLUMN_1>
                    
                                <cfset strSQL = "scf_SCFVM18_CreationStep2_AddressesPhones #thread.intNewHRPersonIDNo#, '#dteHire#', #EMP_ADDRESS_TYPE#, '#strAddress1#', '#strAddress2#', '#strCity#', #intStateID#, '#strZIP#', #USA#, '#strHomePhone#', '#strCellPhone#', '#strWorkPhone#', '#strWorkExt#', #intPhonePrimaryID#  ">
								<!---cfquery name="qryCreationStep2_AddressesPhones" datasource="WFCSuiteTest"--->
								<cfquery name="qryCreationStep2_AddressesPhones" datasource="EPAR">
									scf_SCFVM18_CreationStep2_AddressesPhones #thread.intNewHRPersonIDNo#, '#dteHire#', #EMP_ADDRESS_TYPE#, '#strAddress1#', '#strAddress2#',
										'#strCity#', #intStateID#, '#strZIP#', #USA#, '#strHomePhone#', '#strCellPhone#', '#strWorkPhone#', '#strWorkExt#', #intPhonePrimaryID#
								</cfquery>
								
								<cfset thread.lngResult = qryCreationStep2_AddressesPhones.Error>
								<cfif thread.lngResult EQ 0>
									<!---Step 2 was successful, now let's move on to Step 3, Emergency Contacts --->
									<cfset intContactOrder = 1>
									<cfloop query="qryGetEmpECInfo">   
										<cfset strECHomePhone = DisplayPhone(HomePhone)>	
										<cfset strECCellPhone = DisplayPhone(CellPhone)>	
										<cfset strECWorkPhone = DisplayPhone(WorkPhone)>
										<cfset strSQL = "scf_SCFVM18_CreationStep3_EmergencyContact #thread.intNewHRPersonIDNo#, '#dteHire#', '#First#', '#Last#', #RelationID#, #intContactOrder#, #EMP_ADDRESS_TYPE#, '#Address1#', '#Address2#', '#City#', #State#, '#ZIP#', #USA#, '#strECHomePhone#', '#strECCellPhone#', '#strECWorkPhone#', '#WorkPhoneExt#', #PhonePrimaryID#	  ">	
										<!---cfquery name="qryCreationStep3_EmergencyContacts" datasource="WFCSuiteTest"--->       
										<cfquery name="qryCreationStep3_EmergencyContacts" datasource="EPAR">        
											scf_SCFVM18_CreationStep3_EmergencyContact #thread.intNewHRPersonIDNo#, '#dteHire#', '#First#', '#Last#', #RelationID#, #intContactOrder#,
												 #EMP_ADDRESS_TYPE#, '#Address1#', '#Address2#', '#City#', #State#, '#ZIP#', #USA#, '#strECHomePhone#', '#strECCellPhone#', 
												 '#strECWorkPhone#', '#WorkPhoneExt#', #PhonePrimaryID#	
										</cfquery>
										
										<cfif qryCreationStep3_EmergencyContacts.Error NEQ 0>
											<cfset thread.strHRResult &= "Error creating Emergency Contact record for #First# #Last#.  Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">
											<cfset thread.lngResult = qryCreationStep3_EmergencyContacts.Error>
										</cfif>
										
										<cfset intContactOrder += 1> 
										
									</cfloop>
													   
									<cfif thread.strHRResult EQ ''>
										<cfset thread.lngResult = 0>
									</cfif> 
									
								<cfelse>
									<!--- Error.  Don't proceed.  Post a description of what was successful and what must still be done by hand --->
									<cfset thread.strHRResult &= "The initial HR record creation was successful but there was an error adding the Employee\'s address(es) and phone(s).  The Address(es) and Phone(s) and Emergency Contacts (if any) must still be added.  Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">
												   
								</cfif>
                        
							<cfelse>
								<!--- Error.  Don't proceed.  Post a description of what was successful and what must still be done by hand --->  
									<cfset thread.strHRResult &= "There  was an error creating the initial HR record for the Employee.  The Employment Status, Pay, Personal Information, Address(es), Phone(s) and Emergency Contacts (if any) may still need to be added.  Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">         
							</cfif>
							
						</cfif><!---End hire/rehire--->
                            
                        <cfif thread.lngResult NEQ 0>
                            <cfset thread.strHRResult = 'Failed to complete Kronos HR record creation:<BR/>' & thread.strHRResult />
							<cfmail to="#Session.ITS_EMAIL#; #Session.strUserID#@scf.cc" From="EPAR_Error@scf.cc" subject="EPAR Error:  Creating Kronos HR Prod Record" type="html">
								Error generating the Kronos HR Prod record: <BR />#replace(thread.strHRResult,"\'","'","all")#<BR /><BR />
								Step ID: #intStepID#<BR />
								Action by User (Rosetta ID): #Session.intUserRosettaID#<BR/>
								SQL: #strSQL#
							</cfmail>
                        <cfelse>
                            <cfset thread.strHRResult ='<strong>Success</strong>'>      
                            
                        </cfif>
                    
                    <cfelse>
                        <cfset thread.strHRResult = 'AD Account was not created. Kronos HR record will not proceed.<BR/>' />
                    </cfif> <!--- End AD Status Check --->
                    
                    <cfcatch type="any">
                        <cfset thread.strHRResult &= ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#<BR/>Last SQL: #replace(strSQL,"'","\'","all")#'>
                        <cfset thread.lngResult = -1>
						<cfif CFCATCH.message EQ "Error Executing Database Query." AND thread.intNewHRPersonIDNo NEQ 0><!--- If it's a rehire and fails on the SQL, don't report an error to the Rosetta Thread.  We want to go ahead and add the Rosetta Record --->
                        	<cfset variables.bolError = False>
						<cfelse>
                        	<cfset variables.bolError = True>
						</cfif>
                        <cfquery name="qryInsertErrorLog" datasource="EPAR">
                            scf_InsertErrorLog #intStepID#, #Session.intUserRosettaID#, N'Error generating the Kronos HR Prod record: #replace(thread.strHRResult,"\'","'","all")#'
                        </cfquery>
                        <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Error@scf.cc" subject="EPAR Error:  Creating Kronos HR Prod Record" type="html">
                            Error generating the Kronos HR Prod record: <BR />#replace(thread.strHRResult,"\'","'","all")#<BR /><BR />
                            Step ID: #intStepID#<BR />
                            Action by User (Rosetta ID): #Session.intUserRosettaID#
                        </cfmail>
                    </cfcatch>
        
                </cftry>
                
                <!--- For display purposes only --->     
                <cfscript> 
                    sleep(1000);
                </cfscript>
                    
            </cfthread>
           
           
            <cfthread name='thdRosetta' action='run' priority='low'>     
                <cftry>
                    <cfset thread.intRosettaID = 0>  
                    <cfset thread.intEPAR_ID = 0>  
                    <cfset thread.strRosResult ="">  
                    <cfset thread.bolRosettaStarted = False>       
                    <cfloop condition="thdHRProd.Status NEQ 'COMPLETED' and thdHRProd.Status NEQ 'TERMINATED'">
                        <cfscript>
                            sleep(100);
                        </cfscript>
                    </cfloop>
                    
                    <cfset thread.bolRosettaStarted = True>
                    <!---cfif thdHRProd.Status EQ 'COMPLETED' and thdHRProd.lngResult EQ 0 and not variables.bolError--->
                    <cfif thdHRProd.Status EQ 'COMPLETED' and (thdHRProd.intNewHRPersonIDNo NEQ 0) and not variables.bolError>
					
                        <cfset thread.strUserID = thdAD.strNewUserID>
                        <cfset thread.strAD_GUID = thdAD.strNewADGUID>
                        <cfset thread.intHRProdID = thdHRProd.intNewHRPersonIDNo>
                        <cfset thread.intEPAR_ID = variables.intEmpID>  
                    
                        <!---cfquery name="qryCreateRosettaRecord" datasource="RosettaStone">
                            scf_CreateRosettaRecord '#thread.strUserID#', '#thread.strAD_GUID#', #thread.intHRProdID#, #thread.intEPAR_ID# 
                        </cfquery--->
                    
                        <cfif thread.strUserID EQ '' and thread.intHRProdID EQ 0> 
                        	<cfset variables.bolError = True>    
                            <cfset thread.strRosResult ="There was a problem creating the employee\'s LAN account.  Rosetta Stone record will NOT be created.  The Service Desk has been notified of the error and you will be notified of a resolution shortly."> 
                            <!---cfmail to="helpdesk@scf.cc;sjohnston@scf.cc" from="EPAR@scf.cc" subject="EPAR ERROR:  Creating User Account"---> 
                            <cfmail to="#Session.SERVICEDESK_EMAIL#" from="EPAR@scf.cc" subject="EPAR ERROR:  Creating User Account" type="html">
                                <strong>AD Result:</strong><BR/>
                                &nbsp;&nbsp;&nbsp;&nbsp;Thread Status = #thdAD.Status#<BR/>
                                &nbsp;&nbsp;&nbsp;&nbsp;Thread Result = #thdAD.strADResult#<BR/><BR />
                                <strong>HR Result:</strong><BR/>
                                &nbsp;&nbsp;&nbsp;&nbsp;Thread Status = #thdHRProd.Status#<BR/>
                                &nbsp;&nbsp;&nbsp;&nbsp;Thread Result = #thdHRProd.strHRResult# <BR/><BR />
                                <strong>Rosetta Result:</strong><BR/>
                                &nbsp;&nbsp;&nbsp;&nbsp;Thread Status = #thread.Status#<BR/>
                                &nbsp;&nbsp;&nbsp;&nbsp;Thread Result = #thread.strRosResult# <BR/><BR />                    
                            </cfmail>
                            
                        <cfelse>
                            <cfquery name="qryCreateRosettaRecord" datasource="RosettaStone">
                                scf_CreateRosettaRecord 
                                    <cfif thread.strUserID EQ ''>NULL<cfelse>'#thread.strUserID#'</cfif>, 
                                    <cfif thread.strAD_GUID EQ ''>NULL<cfelse>'#thread.strAD_GUID#'</cfif>, 
                                    <cfif thread.intHRProdID EQ 0 or thread.intHRProdID EQ ''>NULL<cfelse>#thread.intHRProdID#</cfif>, 
                                    <cfif thread.intEPAR_ID EQ 0 or thread.intEPAR_ID EQ ''>NULL<cfelse>#thread.intEPAR_ID#</cfif> 
                            </cfquery>
                            
                            <cfset thread.intRosettaID = qryCreateRosettaRecord.NewRosettaID>
                            
                            <cfif thread.strUserID NEQ '' and thread.intHRProdID EQ 0>
								<!--- no longer possible now that intNewHRPersonIDNo (intHRProdID) is in the condition to start this code section (see line #659 = <cfif thdHRProd.Status EQ 'COMPLETED' ...   >  )--->
                                <cfset thread.strRosResult = "The Rosetta Stone Record was created, but there was a problem creating the employee\'s HR record.  The Network Account has been created. You\'ll need to manually add the employee to Kronos HR.  After the employee has been added, please notify the Service Desk so that the mapping can be completed in Rosetta Stone.">
                            <cfelseif thread.strUserID NEQ '' and thread.intHRProdID GT 0> 
                                 <cfset thread.strRosResult = "<strong>Success</strong>">
                                <cfmail bcc="#Session.ITS_EMAIL#" to="#strSupEmail#" from="""HR Dept - EPAR System"" <noreply@scf.cc>"  type="html" subject="Employee Hire Update">
                                <!---cfmail to=#Session.ITS_EMAIL# from="helpdesk@scf.cc" type="html" subject="Employee Hire Update"---> 
                                    <p>The employee, <strong>#strEmployeeNameDisplay#</strong>, is now in the SCF system.  Here is some information regarding their status and user account.<BR /></p>
                                    <table>
                                        <tr>
                                            <td width=5>&nbsp;
                                                                     	
                                            </td>
                                            <td> 
                                                Network User Account:                           	
                                            </td>
                                            <td width=25>&nbsp;
                                                                     	
                                            </td>
                                            <td> 
                                                #thread.strUserID#                         	
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;
                                                                     	
                                            </td>
                                            <td> 
                                                Password (required to change @ first login):                           	
                                            </td>
                                            <td>&nbsp;</td>
                                            <td> 
                                                Password10! (case sensitive)                       	
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;
                                                                     	
                                            </td>
                                            <td> 
                                                Date of Hire:                           	
                                            </td>
                                            <td>&nbsp;</td>
                                            <td> 
                                                #dteHire#                         	
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;
                                                                     	
                                            </td>
                                            <td> 
                                                Desk Phone:<BR />(as it will appear in the Address Book)                           	
                                            </td>
                                            <td>&nbsp;</td>
                                            <td> 
                                                #strPhone#                         	
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;
                                                                     	
                                            </td>
                                            <td> 
                                                Job Title:                           	
                                            </td>
                                            <td>&nbsp;</td>
                                            <td> 
                                                #strJobTitle#                         	
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;
                                                                     	
                                            </td>
                                            <td> 
                                                Home Directory:                           	
                                            </td>
                                            <td>&nbsp;</td>
                                            <td> 
                                                #strHomeDirLoc#\#thread.strUserID#                     	
                                            </td>
                                        </tr>
                                    </table>                    	
                                </cfmail> 
                            </cfif>                            	
                            
                        </cfif>
                    
                    <cfelse>
                        <cfset thread.strRosResult &= 'Not Started due to previous error'>
                    </cfif>   
                
                    <cfcatch type="any">
                        <cfset thread.strRosResult &= '<BR> #CFCATCH.Detail#'>
                        <cfset thread.lngResult = -1>
                        <cfset variables.bolError = True>
                        <cfquery name="qryInsertErrorLog" datasource="EPAR">
                            scf_InsertErrorLog #intStepID#, '#Session.intUserRosettaID#', N'Error creating the Rosetta Stone record: #CFCATCH.Detail#'
                        </cfquery>
                        <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Error@scf.cc" subject="EPAR Error:  Creating Rosetta Stone Record" type="html">
                            Error creating the Rosetta Stone record: #CFCATCH.Detail#<BR /><BR />
                            Step ID: #intStepID#<BR />
							Supervisor Email: #strSupUserID#@scf.cc<BR />
                            Action by User (Rosetta ID): #Session.intUserRosettaID#
                        </cfmail>
                    </cfcatch>
        
                </cftry>
                
                <!--- For display purposes only --->  
                <cfscript> 
                    sleep(2500);
                </cfscript> 
            </cfthread>
            
            
            <cfthread name='thdFinal' action='run' priority='low'>
                <cftry>
                    <cfset thread.bolFinalStarted = True>
                    <cfloop condition="thdRosetta.Status NEQ 'COMPLETED' and thdRosetta.Status NEQ 'TERMINATED'">
                        <cfscript>
                            sleep(100);
                        </cfscript>
                    </cfloop>
                    
                    <cfif not variables.bolError>
                        <cfif (thdRosetta.Status EQ 'COMPLETED' or thdRosetta.Status EQ 'TERMINATED') and not variables.bolError>
                            <cfquery name="qryStep3UpdateAction" datasource="EPAR">
                                scf_UpdateAction #intStepID#, #Session.intUserRosettaID#, 'Auto Generated'
                            </cfquery>
                            <cfquery name="qryStep3InsertAction" datasource="EPAR">
                                scf_InsertAction #intEmpID#, 5 
                            </cfquery>
                        
                            <!--- For display purposes only --->  
                            <cfscript> 
                                sleep(1500);
                            </cfscript> 
                        
                        </cfif> 
                    </cfif>
                    
                    <cfcatch type="any">
                        <cfquery name="qryInsertErrorLog" datasource="EPAR">
                            scf_InsertErrorLog #intStepID#, '#Session.intUserRosettaID#', 'Error finalizing the step.'
                        </cfquery>
                        <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Error@scf.cc" subject="EPAR Error:  Advancing the Step" type="html">
                            Error advancing the step: #CFCATCH.Detail#<BR /><BR />
                            Step ID: #intStepID# ... Step 4 to 5<BR />
                            Action by User (Rosetta ID): #Session.intUserRosettaID#
                            
                        </cfmail>
                    </cfcatch>
        
                </cftry>
            </cfthread>
            
            <cfset BLANK = "images/blank.jpg">
            <cfset LOAD = "images/rotator.gif">
            <cfset SOURCE = "http://www.scfdev.net/E-PAR/">
        
            <cfoutput>      
            <!-- start header -->
                <cfinclude template="header.cfm"/>
            <!-- end header -->
            

            <!-- start page -->
            <div id="page">	
                <div id="menu">
                    <table>
                        <tr>
                            <td><a href="index.cfm">Home</a></td>
                            <td class="active"><a href="status.cfm">Status</a></td>
                            <td><a href="stats.cfm">Statistics</a></td>
                        </tr>
                    </table>
                </div>
                <!-- start content -->
                <div id="content">
                    <div class="post">
                        <!---p class="date">#dateformat(now(), "mmmm")# <b>#dateformat(now(), "d")#</b></p--->
                        <h1 class="title">Step 3: Create Employee Records</h1>
                        <div class="entry">
                            <p>The creation of the employee records has been initiated for <strong>#strEmployeeNameDisplay#</strong>. Please wait while E-PAR generates the following system records:</p>
                            <table>
                                <tr>
                                    <td width=25>&nbsp;         	
                                    </td>
                                    <td>
                                        <table>
                                            <tr>
                                                <td valign=top>
                                                    Network Account: 
                                                </td>
                                                <td valign=top width=75%>
                                                    <span id="divAD" class="error"></span>&nbsp;<img id="imgAD" src="#BLANK#" />
                                                </td>
                                            </tr>
                                            <!---tr>
                                                <td>
                                                    Employee Master Record:
                                                </td>
                                                <td>
                                                    <span id="divEmpMaster" class="error"></span>&nbsp;<img id="imgEmpMaster" src="#BLANK#" />
                                                </td>
                                            </tr--->
                                            <tr>
                                                <td valign=top>
                                                    HR Employee Record:   
                                                </td>
                                                <td valign=top>  
                                                    <span id="divHRProd" class="error"></span>&nbsp;<img id="imgHRProd" src="#BLANK#" />   	
                                                </td>
                                            </tr>
                                            <tr>
                                                <td valign=top nowrap="nowrap">
                                                    Rosetta Stone Record: 
                                                </td>
                                                <td valign=top>
                                                    <span id="divRosetta" class="error"></span>&nbsp;<img id="imgRosetta" src="#BLANK#" />  
                                                </td>
                                            </tr>
                                        </table>	                            	
                                    </td>
                                </tr>
                                <tr>
                                    <td width=25>&nbsp;
                                                                        
                                    </td>
                                </tr>
                                <tr>
                                    <td width=25>&nbsp;
                                                                        
                                    </td>
                                    <td>
                                        <img id="imgStatus" src="#BLANK#" />&nbsp;<span id="divNotice" class="error">During this time, please refrain from refreshing the page.</span>                            	
                                    </td>
                                </tr>
                            </table>	
                            
                            
                        </div>
                    </div>
                </div>
                <!-- end content -->
                
                <!-- start sidebar -->
                    <cfinclude template="sidebar.cfm"/>
                <!-- end sidebar -->
            </div>
            <!-- end page -->
        	<cfinclude template="footer.cfm">  
            
            <cfloop condition="thdFinal.Status NEQ 'COMPLETED' and thdFinal.Status NEQ 'TERMINATED'">
                <cfscript>
                    sleep(250);
                </cfscript>	
                <!---cfoutput>
                    <script type="text/javascript">	
                         document.getElementById('divADStatus').innerHTML = '#thdAD.Status# #thdHRProd.Status# ';	
                    </script>
                </cfoutput>
                <cfflush/--->
                <cfif isdefined("thdAD.Status")>
                    <cfif thdAD.Status NEQ 'COMPLETED' and thdAD.Status NEQ 'TERMINATED'>
                        <cfif thdAD.bolADStarted>
                            <cfoutput>
                                <script type="text/javascript">			
                                   //if (document.getElementById('imgAD').src == "#SOURCE##BLANK#")
                                        document.getElementById('imgAD').src = '#LOAD#';
                                </script>
                            </cfoutput>
                        </cfif>
                   <cfelse>
                        <script type="text/javascript">
                            document.getElementById('divAD').innerHTML = "#replace(thdAD.strADResult,'\','\\','all')#";	
                            document.getElementById('imgAD').src = '#BLANK#';
                        </script>       
                   </cfif>
                </cfif>
                <cfif isdefined("thdHRProd.Status")>
                    <cfif thdHRProd.Status NEQ 'COMPLETED' and thdHRProd.Status NEQ 'TERMINATED'>
                        <cfif thdHRProd.bolHRStarted>
                            <cfoutput>
                                <script type="text/javascript">
                                    //if (document.getElementById('imgHRProd').src == "#SOURCE##BLANK#") {
                                        document.getElementById('imgHRProd').src = '#LOAD#';
                                        document.getElementById('divHRProd').innerHTML = '';	
                                     //   }
                                </script>
                            </cfoutput>
                        <cfelse>
                            <cfoutput>
                                <script type="text/javascript">
                                    document.getElementById('divHRProd').innerHTML = 'Waiting ...';	
                                </script>
                            </cfoutput>
                        </cfif>
                   <cfelse>
                        <script type="text/javascript">
                            document.getElementById('divHRProd').innerHTML = '#thdHRProd.strHRResult#';
                            document.getElementById('imgHRProd').src = '#BLANK#';
                        </script>       
                   </cfif>
                </cfif>
                <cfif isdefined("thdRosetta.Status")>
                    <cfif thdRosetta.Status NEQ 'COMPLETED' and thdRosetta.Status NEQ 'TERMINATED'>
                        <cfif thdRosetta.bolRosettaStarted>
                            <cfoutput>
                                <script type="text/javascript">
                                    //if (document.getElementById('imgRosetta').src == "#SOURCE##BLANK#") {
                                        document.getElementById('imgRosetta').src = '#LOAD#';
                                        document.getElementById('divRosetta').innerHTML = '';								
                                     //   }
                                </script>
                            </cfoutput>
                        <cfelse>
                            <cfoutput>
                                <script type="text/javascript">
                                    document.getElementById('divRosetta').innerHTML = 'Waiting ...';	
                                </script>
                            </cfoutput> 
                        </cfif>
                   <cfelse>
                        <script type="text/javascript">
                            document.getElementById('divRosetta').innerHTML = '#thdRosetta.strRosResult#';
                            document.getElementById('imgRosetta').src = '#BLANK#';
                        </script>       
                   </cfif>
                </cfif>
                <cfif isdefined("thdFinal.Status")>
                    <cfif thdFinal.Status NEQ 'COMPLETED' and thdFinal.Status NEQ 'TERMINATED'>
                        <cfif thdFinal.bolFinalStarted>
                            <cfoutput>
                                <script type="text/javascript">
                                    //if (document.getElementById('imgStatus').src == "#SOURCE##BLANK#")
                                        document.getElementById('imgStatus').src = '#LOAD#';
                                </script>
                            </cfoutput>   
                        </cfif>         
                   <cfelse>
                        <script type="text/javascript">
                            //document.getElementById('divNotice').innerHTML = "Thank you for using E-PAR. A status update has been sent via email to the supervisor.<BR/>Enter 'Orientation' data for another user?  Click <a href='Step3-Orientation1.cfm'>Here</a><Br/><BR>ADStatus: #thdAD.Status#<BR/>HRStatus: #thdHRProd.Status#<BR/>RosettaStatus: #thdRosetta.Status#<BR/>FinalStatus: #thdFinal.Status#<BR/>";
							document.getElementById('divNotice').innerHTML = "Thank you for using E-PAR. A status update has been sent via email to the supervisor.<BR/>Enter 'Orientation' data for another user?  Click <a href='Step3-Orientation1.cfm'>Here</a>";
                            document.getElementById('imgStatus').src = '#BLANK#';
                        </script>       
                   </cfif>
                </cfif>
                <cfflush />	
            </cfloop>    
            
        	</cfoutput>  
            </body>
        
        
        </cfif> 
    <cfelse>
    	<cflocation url="status.cfm">
	</cfif>
<cfelse>
	<cfinclude template="Denied.cfm">
</cfif> 
</html>
